//
//  UIView+XNProgressHUD.m
//  CheFu365
//
//  Created by safiri on 2018/4/12.
//  Copyright © 2018年 safiri. All rights reserved.
//

#import "UIView+XNProgressHUD.h"
#import <objc/runtime.h>

static char ViewXNProgressHUD;

@implementation UIView (XNProgressHUD)

- (void)setHud:(XNProgressHUD *)hud {
    objc_setAssociatedObject(self, &ViewXNProgressHUD, hud, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (XNProgressHUD *)hud {
    XNProgressHUD *hudView = objc_getAssociatedObject(self, &ViewXNProgressHUD);
    if(!hudView) {
        hudView = [[XNProgressHUD alloc] init];
        hudView.targetView = self;
        hudView.position = CGPointMake(self.frame.size.width/2, self.frame.size.height/2);
        [self setHud:hudView];
    }
    return hudView;
}

@end
